package com.zmn.oms.api.controller.third.baidu_dtw;

import com.zmn.oms.common.dto.ResultDTO;
import com.zmn.oms.common.utils.RequestUtil;
import com.zmn.oms.third.baidu_dtw.BaiduDtwConsts;
import com.zmn.oms.third.baidu_dtw.service.BaiduDtwService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 类描述：
 *
 * @author lhl
 * @date 2020/01/16 11:39
 */
@RestController
@RequestMapping("/baidu/dtw")
@Slf4j
public class BaiduDtwController {

    @Autowired
    private BaiduDtwService baiduDtwService;

    @RequestMapping("/order_3")
    @ResponseBody
    public ResultDTO order_3(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]", BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_3);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_32")
    @ResponseBody
    public ResultDTO order_32(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]", BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_32);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_11")
    @ResponseBody
    public ResultDTO order_11(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_11);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }


    @RequestMapping("/order_101")
    @ResponseBody
    public ResultDTO order_101(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_101);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_102")
    @ResponseBody
    public ResultDTO order_102(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_102);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_103")
    @ResponseBody
    public ResultDTO order_103(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_103);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_104")
    @ResponseBody
    public ResultDTO order_104(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_104);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_105")
    @ResponseBody
    public ResultDTO order_105(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_105);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_106")
    @ResponseBody
    public ResultDTO order_106(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_106);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_107")
    @ResponseBody
    public ResultDTO order_107(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_107);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_108")
    @ResponseBody
    public ResultDTO order_108(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_108);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_109")
    @ResponseBody
    public ResultDTO order_109(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_109);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_110")
    @ResponseBody
    public ResultDTO order_110(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_110);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_111")
    @ResponseBody
    public ResultDTO order_111(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_111);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_112")
    @ResponseBody
    public ResultDTO order_112(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_112);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_113")
    @ResponseBody
    public ResultDTO order_113(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_113);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }

    @RequestMapping("/order_114")
    @ResponseBody
    public ResultDTO order_114(HttpServletRequest request) {
        String paramsStr = RequestUtil.getPostParameter(request);
        log.info("【{}】收到新单消息！ Body:[{}]",  BaiduDtwConsts.NAME, paramsStr);

        try {
            baiduDtwService.procMsg(paramsStr, BaiduDtwConsts.CHANNEL_ID_114);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultDTO.fail("失败");
        }

        return ResultDTO.success();
    }
}
